package cn.iocoder.yudao.module.statistics.api;

import cn.iocoder.yudao.module.statistics.api.statistics.ProductStatisticsApi;
import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductSalesVolumeRespVO;
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class ProductStatisticsApiImpl implements ProductStatisticsApi {

    @Resource
    private TradeStatisticsService tradeStatisticsService;
    @Override
    public Integer getProductSalesCount(Long id) {
        ProductSalesVolumeRespVO salesVolume = tradeStatisticsService.getSalesVolume(id);
        if (salesVolume != null) {
            return salesVolume.getNum();
        }
        return 0;
    }
}
